﻿using MediatR;
using T.Materials.Domain.Model;
using T.Materials.Read.API.ApplicationRead.Command.EconomizeCommand;
using T.Materials.Repository.MaterialsInterface;

namespace T.Materials.Read.API.ApplicationRead.CommandHandler.EconomizeCommandHandler
{
    /// <summary>
    /// 
    /// </summary>
    public class ShowEconomizeCommandHandler : IRequestHandler<ShowEconomizeCommand, List<Economize>>
    {
        /// <summary>
        /// 
        /// </summary>
        protected readonly IEconomizeRepository economizeRepository;

        public ShowEconomizeCommandHandler(IEconomizeRepository economizeRepository)
        {
            this.economizeRepository = economizeRepository;
        }

        /// <summary>
        /// 获取省/州列表
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<List<Economize>> Handle(ShowEconomizeCommand request, CancellationToken cancellationToken)
        {
            var list = await economizeRepository.GetAsync(x => x.CountryId == request.CountryId);
            return list.ToList();
        }
    }
}
